

package cn.shengchao.config.websocket;

import top.continew.admin.common.model.dto.LoginUser;
import cn.shengchao.util.helper.LoginHelper;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.stereotype.Component;
import top.continew.starter.messaging.websocket.core.WebSocketClientService;

/**
 * 当前登录用户 Provider
 *
 * @author Charles7c
 * @since 2024/6/4 22:13
 */
@Component
public class WebSocketClientServiceImpl implements WebSocketClientService {

    @Override
    public String getClientId(ServletServerHttpRequest request) {
        HttpServletRequest servletRequest = request.getServletRequest();
        String token = servletRequest.getParameter("token");
        LoginUser loginUser = LoginHelper.getLoginUser(token);
        return loginUser.getToken();
    }
}
